<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 有效的山脉数组 -->
    <script>
      var validMountainArray = function (A) {
        let s1 = 0,
          s2 = 0

        for (let i = 0; i < A.length - 1; i++) {
          if (A[i] < A[i + 1]) {
            s2 = 1
            if (s1 == 1) return false
          } else if (A[i] > A[i + 1]) {
            s1 = 1
          } else return false
        }
        return s1 == 1 && s2 == 1 && A.length > 2 ? true : false
      }
      // console.log(validMountainArray([2, 1]))
      // console.log(validMountainArray([3, 5, 5]))
      console.log(validMountainArray([0, 3, 2, 1]))
    </script>
  </body>
</html>
